﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class RecipeOperate : IRecipeOperate
    {
        private HcDbContext _db { get; set; }
        public RecipeOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<Recipe> GetAllRecipeList()
        {

            return _db.Recipes.ToList();
        }

        public Recipe GetRecipeById(string id)
        {
            return _db.Recipes.SingleOrDefault(i => i.RecipeId == id);
        }

        public List<Recipe> GetRecipeByIdList(List<string> ids)
        {
            return _db.Recipes.Where(i => ids.Contains(i.RecipeId)).ToList();
        }

        public void AddRecipe(Recipe entity)
        {
            _db.Recipes.Add(entity);
        }

        public void UpdateRecipe(Recipe entity)
        {
            _db.Recipes.Update(entity);
        }

        public void DeleteRecipe(Recipe entity)
        {
            _db.Recipes.Remove(entity);
        }

        public void BatchDelRecipe(List<Recipe> entity)
        {
            _db.Recipes.RemoveRange(entity);

        }
    }
}
